function msgFn(title) { uni.showToast({ title, icon: 'none' }) }

/** 声音波纹工具 */
export class AudioCorrugationUtils {

	/** 渲染倒计时 */
	audioBowenTimer = null;

	/** 音频dom对象 */
	audioDom = null;

	/** 播放音频 */
	play(url = "") {
		if (!url) return msgFn('无效的播放地址');
		if (url == this.audioDom.src) this.audioDom.play();
		else {
			this.audioDom.src = url;
			this.audioDom.autoplay = true;
		}
	}

	/** 暂停播放 */
	pause() { this.audioDom && this.audioDom.pause(); }

	/** 销毁计时器 */
	destroyTimer() { clearInterval(this.audioBowenTimer); }

	/** 容器高度 */
	height;

	constructor(height = 100, callback, endedCallBack) {
		const audio = this.audioDom = uni.createInnerAudioContext();
		audio.volume = 1;
		this.height = height;

		audio.onEnded(() => {
			console.log("audio end");
			endedCallBack && endedCallBack()
		})

		audio.onPlay(() => {
			console.log("audio play");
		})

		audio.onPause(() => {
			console.log("audio pause");
		})

	}
}